package com.briup.cms.web.controller;
/**
 * @program: Consult_Management_Syetem1
 * @description:
 * @author: 张琰
 * @create: 2020-07-02*
 **/
import com.briup.cms.bean.Privilege;
import com.briup.cms.bean.Role_privilege;

import com.briup.cms.service.IRole_privilegeService;

import com.briup.cms.utils.Message;
import com.briup.cms.utils.MessageUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
@Api(description = "测试接口")
@RestController
@RequestMapping("/roleprivilege")
public class Role_privilegeController {
    @Autowired
    private IRole_privilegeService role_privilegeService;

    @ApiOperation("查询所有")
    @GetMapping("findAll")
    public Message findAll(){
        List<Role_privilege> list = role_privilegeService.findAll();
        return MessageUtil.success(list);
    }

    @ApiOperation("保存或更新")
    @PostMapping("saveOrUpdate")
    public Message saveOrUpdate(Role_privilege role_privilege){
        role_privilegeService.saveOrUpdate(role_privilege);
        return MessageUtil.success("操作成功");
    }

    @ApiOperation("根据id删除")
    @GetMapping("deleteById")
    @ApiImplicitParams(
            @ApiImplicitParam(name = "id",value = "主键", required = true,paramType = "query")
    )
    public Message deleteById(long id){
        role_privilegeService.deleteById(id);
        return MessageUtil.success("删除成功");
    }

}
